package cn.kgc.mushroomdatabaseprovider.controller;

import cn.kgc.mushroomcommon.pojo.Coll;
import cn.kgc.mushroomcommon.pojo.Shop;
import cn.kgc.mushroomcommon.vo.ShopVO;
import cn.kgc.mushroomdatabaseprovider.service.ShopService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 项目名：mushroom
 * 创建人：Junyizm
 * 创建时间：2020/4/27-22:11
 */
@RestController
@RequestMapping("/shop/provider")
public class ShopController {

    @Resource
    ShopService shopService;


    @RequestMapping("/shop/provider/selectshopbyname")
    public List<ShopVO> selectshopByName(@RequestParam("shopName")String shopName){
        List<ShopVO> shopVOS = shopService.selectShopByName(shopName);
        return shopVOS;
    }

    @RequestMapping("/selectall")
    public List<Shop> selectall(){
         List<Shop> shops = shopService.selectAll();
        return  shops;
    }


    @RequestMapping("/selectByid")
    public Shop selectById(@RequestParam("id")Integer id){
         Shop shop = shopService.selectByid(id);
         return shop;
    }


    @RequestMapping("/selectShopComId")
    public Shop selectShopComId(@RequestParam("id")Integer id){
        Shop shops = shopService.selectShopComId(id);
        return  shops;
    }

    @RequestMapping("/insertshopanduser")
    public Map<String,Object> insertshopanduser(@RequestParam("shopcollid")Integer shopcollid,@RequestParam("userid")Integer userid){
        Map<String,Object> map = new HashMap<>();
         int insertshopanduser = shopService.insertshopanduser(shopcollid, userid);
         if(insertshopanduser>0){
             map.put("status","添加成功");
         }else{
             map.put("status","添加失败");
         }
         return map;
    }


    @RequestMapping("/selectColl")
    public List<Coll> selectColl(@RequestParam("userid")Integer userid){
        List<Coll> Coll = shopService.selectCollShop(userid);
        return  Coll;
    }


}
